﻿using ChikovMF.Application.Features.Projects.Shared;
using ChikovMF.Entities;
using MediatR;

namespace ChikovMF.Application.Features.Projects.EditProject;

public class EditProjectCommand : ProjectModel, IRequest<Guid>
{
    public Guid ProjectId { get; set; }

    internal void UpdateProject(Project project)
    {
        project.Name = this.Name;
        project.Description = this.Description;
        project.Content = this.Content;

        project.Links = this.Links?.Select(l => new Link
        {
            Name = l.Name,
            Url = l.Url
        }).ToList();

        project.TagLinks = this.Tags?.Select(t => new ProjectTag
        {
            Order = t.Order,
            TagId = t.TagId
        }).ToList();
    }
}
